package com.wanli.storemobile.merchant;


import android.os.Bundle;
import android.widget.TextView;

import com.wanli.storemobile.R;
import com.wanli.storemobile.base.BaseActivity;
import com.wanli.storemobile.bean.RechargeListBean;
import com.wanli.storemobile.utils.DateTimeUtil;
import com.wanli.storemobile.utils.NumberFormatUtils;
import com.wanli.storemobile.widget.AppTitleBar;

import java.util.Date;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MerchantRechargeDetailsActivity extends BaseActivity {
    @BindView(R.id.title_bar)
    AppTitleBar titleBar;
    @BindView(R.id.tv_recharge_money)
    TextView tvRechargeMoney;
    @BindView(R.id.tv_send_money)
    TextView tvSendMoney;
    @BindView(R.id.tv_pay_status)
    TextView tvPayStatus;
    @BindView(R.id.tv_shop_type)
    TextView tvShopType;
    @BindView(R.id.tv_store_name)
    TextView tvStoreName;
    @BindView(R.id.tv_pay_time)
    TextView tvPayTime;
    @BindView(R.id.tv_pay_type)
    TextView tvPayType;
    @BindView(R.id.tv_recharge_no)
    TextView tvRechargeNo;
    @BindView(R.id.tv_total_money)
    TextView tvTotalMoney;
    @BindView(R.id.tv_name)
    TextView tvName;
    private RechargeListBean.DataBean.ItemListBean itemListBean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_merchant_recharge_details);
        ButterKnife.bind(this);
        initView();
    }

    public void initView() {
        itemListBean = (RechargeListBean.DataBean.ItemListBean) getIntent().getSerializableExtra("DataBean");

        // 0现金支付,1微信支付,2支付宝支付,3银联云闪付,5NFC,6刷卡交易
        if (itemListBean.getPay_category_id() == 0) {
            tvPayType.setText("现金支付");
        } else if (itemListBean.getPay_category_id() == 1) {
            tvPayType.setText("微信");
        } else if (itemListBean.getPay_category_id() == 2) {
            tvPayType.setText("支付宝");
        } else if (itemListBean.getPay_category_id() == 3) {
            tvPayType.setText("云闪付");
        } else if (itemListBean.getPay_category_id() == 5) {
            tvPayType.setText("NFC");
        } else if (itemListBean.getPay_category_id() == 6) {
            tvPayType.setText("刷卡");
        }
        tvName.setText(itemListBean.getName());
        String rechargeFee = NumberFormatUtils.formatDouble(Double.parseDouble(itemListBean.getRecharge_money()) / 100);
        tvRechargeMoney.setText("+" + rechargeFee);

        String sendMoney = NumberFormatUtils.formatDouble(Double.parseDouble(itemListBean.getSend_money()) / 100);
        tvSendMoney.setText("+" + sendMoney);

        tvTotalMoney.setText("+" + NumberFormatUtils.formatDouble(Double.parseDouble(rechargeFee) + Double.parseDouble(sendMoney)));
        tvPayTime.setText(DateTimeUtil.format7(new Date(Long.parseLong(itemListBean.getPay_time()) * 1000)));
        tvRechargeNo.setText(itemListBean.getMember_money_order_no());
        if (itemListBean.getPay_status() == 1) {
            tvPayStatus.setText("已付款");
        } else {
            tvPayStatus.setText("未付款");
        }
    }
}
